import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import p02 from './p02';
import render from '@feidao/web/atom/browser/render/render';
import get_form_data from '@feidao/web/atom/browser/form/get-data';

export default async function a014(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	fd.data.node.querySelector<HTMLAreaElement>('[data-feidao-id="fd-w000006-003"]').innerHTML = '';
	// 获取属性，渲染p02
	const widgets = fd.data.node.querySelector<HTMLFormElement>('[name="widgets"]');
	const data = get_form_data(widgets);
	let attrs = '';
	for (const attr in data) {
		if (data.hasOwnProperty(attr)) {
			const v = data[attr];
			if (v === true) {
				attrs += attr + ' ';
			} else {
				if (v) {
					attrs += attr + '=\'' + v + '\' ';
				}
			}
		}
	}
	render(fd, attrs, p02, 'p02', 'inner');

	const a = fd.data.node.querySelector<HTMLAreaElement>('[data-feidao-id="fd-w000006-002"]');
	a.innerHTML = `
<fd-w000006 data-feidao-id="fd-w000006-001" style="width:50em;height:30em;display:block;position: absolute;" ${attrs}>
	<div style="width: 10em;height: 1.5em;background: whitesmoke;line-height: 1.5em;margin:0.2em" interval="1" is-before="true"
	  slot="day">
	  今天
	</div>
	<div style="width: 10em;height: 1.5em;background: whitesmoke;line-height: 1.5em;margin:0.2em" interval="2" is-before="true"
	  slot="day">
	  昨天
	</div>
	<div style="width: 10em;height: 1.5em;background: whitesmoke;line-height: 1.5em;margin:0.2em" interval="2" is-before="false"
	  slot="day">
	  明天
	</div>
	<div style="width: 10em;height: 1.5em;background: whitesmoke;line-height: 1.5em;margin:0.2em" interval="7" is-before="true"
	  slot="day">
	  过去的7天
	</div>
	<div style="width: 10em;height: 1.5em;background: whitesmoke;line-height: 1.5em;margin:0.2em" interval="7" is-before="false"
	  slot="day">
	  未来的7天
	</div>
	<div style="width: 10em;height: 1.5em;background: whitesmoke;line-height: 1.5em;margin:0.2em" interval="30" is-before="true"
	  slot="day">
	  过去的30天
	</div>
	<div slot="some">
	</div>
  </fd-w000006>
	`;

}
